#pragma once
#include "../stdafx.h"
#include <boost/bind.hpp>
#include <boost/function.hpp>
namespace SLG
{
#define MOUSE 0
#define KEYBOARD 1
	typedef struct
	{
		DWORD device;
		DWORD key;
		DWORD state;
	}INPUT_STR;

	enum ButtonState
	{
		Press,
		Up,
		Click,
		DoubleClick,
	};

	enum MouseType
	{
		LButton,
		MButton,
		RButton
	};

	enum KeyType
	{
		KeyEscape,
		Key1,
		Key2,
		Key3,
		Key4,
		Key5,
		Key6,
		Key7,
		Key8,
		Key9,
		Key0,
		KeyMinus,
		KeyEquals,
		KeyBack,
		KeyTab,
		KeyQ,
		KeyW,
		KeyE,
		KeyR,
		KeyT,
		KeyY,
		KeyU,
		KeyI,
		KeyO,
		KeyP,
		KeyLBracket,
		KeyRBracket,
		KeyReturn,
		KeyLControl,
		KeyA,
		KeyS,
		KeyD,
		KeyF,
		KeyG,
		KeyH,
		KeyJ,
		KeyK,
		KeyL,
		KeySemicolon,
		KeyApostrophe,
		KeyGrave,
		KeyLShift,
		KeyBackSlash,
		KeyZ,
		KeyX,
		KeyC,
		KeyV,
		KeyB,
		KeyN,
		KeyM,
		KeyComma,
		KeyPeriod,
		KeySlash,
		KeyRShift,
		KeyMultiply,
		KeyLMenu,
		KeySpace,
		KeyCapital,
		KeyF1,
		KeyF2,
		KeyF3,
		KeyF4,
		KeyF5,
		KeyF6,
		KeyF7,
		KeyF8,
		KeyF9,
		KeyF10,
		KeyNumLock,
		KeyScroll,
		KeyNumPad7,
		KeyNumPad8,
		KeyNumPad9,
		KeySubtract,
		KeyNumPad4,
		KeyNumPad5,
		KeyNumPad6,
		KeyAdd,
		KeyNumPad1,
		KeyNumPad2,
		KeyNumPad3,
		KeyNumPad0,
		KeyDecimal,
		KeyOEM_102,
		KeyF11,
		KeyF12,
		KeyF13,
		KeyF14,
		KeyF15,
		KeyKana,
		KeyABNT_C1,
		KeyConvert,
		KeyNoConvert,
		KeyYen,
		KeyABNT_C2,
		KeyNumPadEquals,
		KeyPrevTrack,
		KeyAt,
		KeyColon,
		KeyUnderLine,
		KeyKANJI,
		KeyStop,
		KeyAx,
		KeyUnlabeled,
		KeyNextTrack,
		KeyNumPadEnter,
		KeyRControl,
		KeyMute,
		KeyCalculator,
		KeyPlayPause,
		KeyMediaStop,
		KeyVolumeDown,
		KeyVolumeUp,
		KeyWebHome,
		KeyNumPadComma,
		KeyDivide,
		KeySysRQ,
		KeyRMenu,
		KeyPause,
		KeyHome,
		KeyUp,
		KeyPrior,
		KeyLeft,
		KeyRight,
		KeyEnd,
		KeyDown,
		KeyNext,
		KeyInsert,
		KeyDelete,
		KeyLWin,
		KeyRWin,
		KeyApps
	};

	class Mouse
	{
	public:
		Mouse();
		HRESULT Init(HWND,LPDIRECTINPUT8);
		~Mouse();
		void GetState();
		void SetMouseProc(int button,int state,boost::function<void()>);
		D3DXVECTOR2 GetPoint();
	private:
		bool MouseLeftClicked();
		bool MouseRightClicked();

		void SetLeftButtonProc(boost::function<void()>);
		boost::function<void()> m_LeftButtonProc;

		void SetRightButtonProc(boost::function<void()>);
		boost::function<void()> m_RightButtonProc;
	


		bool m_mouseLeftButton;
		bool m_mouseRightButton;
		DIMOUSESTATE         m_mouseState;
		int32 m_mousePointX;
		int32 m_mousePointY;
		LPDIRECTINPUTDEVICE8		m_mouseDevice;
	};

	class KeyBoard
	{
	public:
		KeyBoard();
		~KeyBoard();
		HRESULT Init(HWND,LPDIRECTINPUT8);
		void GetState();
		void SetKeyBoardProc(int i,boost::function<void()>);
	private:
		bool m_key[132];
		boost::function<void()> m_KeyBoardProc[132];
		bool GetKeyState(KeyType);
		LPDIRECTINPUTDEVICE8		m_keyboardDevice; 
	};

	class InputDevice
	{
	public:
		InputDevice(void);
		HRESULT Init(HWND);
		~InputDevice(void);

		void GetState();
		D3DXVECTOR2 GetPoint();
		bool SetProc(INPUT_STR,boost::function<void()>);
		//bool MouseLeftButton();
		//bool MouseRightButton();
		//bool MouseMiddleButton();

		//bool MouseLeftClicked();
		//bool MouseRightClicked();
		//bool MouseMiddleClicked();

	private:
		
		LPDIRECTINPUT8				m_input;
		Mouse m_mouse;
		KeyBoard m_keyboard;

	};


}
